import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  // 设置路径别名 '@' 指向 /src 目录
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  // 生产环境构建优化
  build: {
    outDir: 'dist',
    assetsDir: 'assets',
    sourcemap: false,
    minify: 'esbuild',
    chunkSizeWarningLimit: 1000,
    rollupOptions: {
      output: {
        manualChunks: {
          vendor: ['vue', 'vue-router', 'pinia'],
          ui: ['@iconify/vue', 'lucide-vue-next']
        }
      }
    }
  },
  // 开发服务器代理配置
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:9901',
        changeOrigin: true,
        secure: false
      }
    }
  }
}) 